/*
 * t_main.c
 *
 *  Created on: 2012-9-19
 *      Author: Administrator
 */
#include <linux/input.h>
#include <string.h>

#include "tangoc.h"
#include "t_debug.h"
#include "t_raster.h"
#include "about.h"

void t_main_menu()
{
	puts("\n[Tune mode] main menu, Press a key in brackes.");
	puts("[B] Bootloader mode.");
	puts("[C] Calibrate mode.");
	puts("[D] Debug mode.");
	puts("[R] raster mode");
	puts("[E] EEPROM mode");
	puts("[I] INT mode");
	puts("[T] TP reset.");
	puts("[A] About me");
	puts("[X] Exit.");
}

int t_execute()
{
	int ret = 0, num, type = 1, loop = 1;
	char cmd, flag = 'n';
	char fname[64] = "/auto.pix";

	t_main_menu();
	while (loop)
	{
		printf("Input cmd: ");
		cmd = getchar();
		while (getchar() != '\n');
		switch (cmd)
		{
		case 't':
		case 'T':
			reset();
			break;
		case 'c':
		case 'C':
			num = 1;
			ret = calibration(num);
			break;
		case 'n':
		case 'N':
			normal_mode();
			break;
		case 'r':
		case 'R':
			t_raster_mode();
			break;
		case 'd':
		case 'D':
			t_debug_mode();
			break;
		case 'b':
		case 'B':
			input_bootloader(fname, &flag);
			ret = bootloader_mode(fname, flag);
			break;
		case 'e':
		case 'E':
			EEPROM_mode();
			break;
		case 'i':
		case 'I':
			INT_mode();
			break;
		case 'a':
		case 'A':
			show_about();
			break;
		case 'x':
		case 'X':
			loop = 0;
			break;
		}
		t_main_menu();
	}
	return ret;
}
